/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.sms.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.validator.constraints.Length;

import com.chlitina.store.common.persistence.BaseEntity;
import com.chlitina.store.modules.expert.entity.CustomerSolutionAndCare;
import com.chlitina.store.modules.expert.entity.CustomerSolutionAndProduct;
import com.google.common.collect.Lists;

/**
 * 店面诊断模板Entity
 * @author liujiang
 * @version 2013-08-01
 */
@Entity
@Table(name = "store_diagnose_template")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class StoreDiagnoseTemplate extends BaseEntity {
	
	private static final long serialVersionUID = 1L;
	private Long id; 		// 店面诊断模版编号
	private String name; 	// 区域店面诊断模版名称
	private StoreDiagnoseFomula storeDiagnoseFomula;  // 理论业绩计算公式类型

	private List<StoreDiagnoseTemplateDetail> detailList = Lists.newArrayList();
	
	public StoreDiagnoseTemplate() {
	}

	public StoreDiagnoseTemplate(Long id){
		this();
		this.id = id;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	@Length(min=1, max=32)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToOne
	@JoinColumn(name="PERFORMANCE_FORMULA")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public StoreDiagnoseFomula getStoreDiagnoseFomula() {
		return storeDiagnoseFomula;
	}

	public void setStoreDiagnoseFomula(StoreDiagnoseFomula storeDiagnoseFomula) {
		this.storeDiagnoseFomula = storeDiagnoseFomula;
	}
	
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="storeDiagnoseTemplate")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<StoreDiagnoseTemplateDetail> getDetailList() {
		return detailList;
	}

	public void setDetailList(List<StoreDiagnoseTemplateDetail> detailList) {
		this.detailList = detailList;
	}
}